﻿namespace RLab.Visualization

open System
open Microsoft.DirectX

module Geometry =
    let pi = (float32) Math.PI

    let O   = Vector3( 0.0f, 0.0f, 0.0f) 
    let X1  = Vector3( 1.0f, 0.0f, 0.0f) 
    let Y1  = Vector3( 0.0f, 1.0f, 0.0f)
    let Z1  = Vector3( 0.0f, 0.0f, 1.0f)

    // multiply matrix 3x3 with vector3
    let inline (@*) (m : Matrix) (v : Vector3) = 
        new Vector3
            (m.M11*v.X + m.M21*v.Y + m.M31*v.Z,
             m.M12*v.X + m.M22*v.Y + m.M32*v.Z,
             m.M13*v.X + m.M23*v.Y + m.M33*v.Z)

    let transformAt v m = Matrix.Translation(v) * m * Matrix.Translation(-v)
    let scale       k u = Vector3.Scale(u,k)
    let translationVector (m : Matrix) = new Vector3(m.M41,m.M42,m.M43)